package android.FiltrosJava;

import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class MarcaLogoSite extends AbstractImageBasic{
	protected BufferedImage sprite = null;	
	protected AbstractImageBasic spriteTrans = null;
	public MarcaLogoSite(BufferedImage img){
		setSprite(img);
	}
	
	public void setSprite(BufferedImage img){
		sprite = img;
	}
		
	public BufferedImage applyFilter(BufferedImage src) {
		
		if (Math.min(src.getHeight(),src.getWidth()) < 350){
			double t = (float) ((float) Math.min(src.getHeight(),src.getWidth()) / ((float)Math.min(sprite.getHeight(),sprite.getWidth())));			
			double tam = (float) (1 - 1/t);			
			ScaleTransform st = new ScaleTransform(tam,tam);
			
			sprite = st.applyFilter(sprite);
		}				
		
		BufferedImage p = createCompatibleDestImage( src );		
		Graphics2D g = p.createGraphics();
		g.drawImage( src, 0, 0, null );		
    	g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
    	    	    	    
    	
    	g.drawImage(sprite, (int)(src.getWidth()-sprite.getWidth()), (int)(src.getHeight()-sprite.getHeight()), null);    	    	    	
		g.dispose();
		
		convertImageToRGB(p);
		return p;
		//return convertImageToRGB(p);
    }
}
